***************************
*HH DATA ANALYSIS**********
*Last edit June 7,2022 KB**
***************************


use "data/Uganda_HHsurvey_HHlevelobs.dta", clear

****************************************************
*JUSTIFYING QUALITY OF PROJECTS STATISTICS (PG. 17)*
****************************************************

sum heardproj usedproject proj_qual
tab proj_qual
tab proj_qual if heardproj==1
tab proj_qual if usedproject==1
bysort a4_subcounty: sum heardproj usedproject proj_qual
bysort a4_subcounty: tab proj_qual
bysort a4_subcounty: tab proj_qual if heardproj==1
bysort a4_subcounty: tab proj_qual if usedproject==1


*********
*TABLE 4*
*********

tabout prior_imp_cat2 prior_fund_cat2 using "priors2.csv", replace ///
 cells(freq cell) format(0 1) style(csv)


***********************************************************
*INFORMATION EFFECTS ON RESPONDENT-POLITICIAN OBSERVATIONS*
***********************************************************

use "data/Uganda_HHsurvey_politicianlevelobs.dta", clear


******************
*TABLE 5**********
******************

sum credit if bypass==0
reg credit bypass i.strata, cluster(id)

sum othersvote if bypass==0
reg othersvote bypass i.strata, cluster(id)

sum vote if bypass==0
reg vote bypass i.strata, cluster(id)

sum credit if bypass==0 & involvement==0
reg credit bypass involvement bypassXinvolvement i.strata, cluster(id)

sum othersvote if bypass==0 & involvement==0
reg othersvote bypass involvement bypassXinvolvement i.strata, cluster(id)

sum vote if bypass==0 & involvement==0
reg vote bypass involvement bypassXinvolvement i.strata, cluster(id)


******************
*FIGURE 5*********
******************


reg credit bypass involvement bypassXinvolvement i.strata, cluster(id)

predictnl diff_2 = _b[bypass]+ _b[bypassXinvolvement]*involvement, se(diff2_se)

gen upper2 = diff_2 + diff2_se*1.96
gen lower2 = diff_2 - diff2_se*1.96

sort diff_2

twoway (dot diff_2 involvement, ndots(1) mcolor(gs2))(rcap upper2 lower2 involvement, lcolor(gs2)), /*
*/     xtitle("Political Oversight Capacity") xlabel(0 1 2) xsize(2.8) scale(1.4) ytitle("Effect of Full Aid Information") ylabel(-.4(.1) .3,nogrid)/*
*/   yscale(range(-.55 .4)) yline(0) title("Credit Due") graphregion(fcolor(white) ifcolor(white) color(white) lcolor(white) ilcolor(white)) legend(off)
	  
graph export "figures_tables/Fig5_LeftPanel_creditdue.tif", replace
	  

reg othersvote bypass involvement bypassXinvolvement i.strata, cluster(id)

predictnl diff_3 = _b[bypass]+ _b[bypassXinvolvement]*involvement, se(diff3_se)

gen upper3 = diff_3 + diff3_se*1.96
gen lower3 = diff_3 - diff3_se*1.96

sort diff_3

twoway (dot diff_3 involvement, ndots(1) mcolor(gs2))(rcap upper3 lower3 involvement, lcolor(gs2)), /*
*/     xtitle("Political Oversight Capacity") xlabel(0 1 2) xsize(2.8) scale(1.4) ytitle("Effect of Full Aid Information") ylabel(-.4(.1) .3,nogrid)/*
*/   yscale(range(-.55 .4)) yline(0) title("Voting Factor") graphregion(fcolor(white) ifcolor(white) color(white) lcolor(white) ilcolor(white)) legend(off)
	  
graph export "figures_tables/Fig5_CenterPanel_votingfactor.tif", replace
	  
	  
reg vote bypass involvement bypassXinvolvement i.strata, cluster(id)

predictnl diff_4 = _b[bypass]+ _b[bypassXinvolvement]*involvement, se(diff4_se)

gen upper4 = diff_4 + diff4_se*1.96
gen lower4 = diff_4 - diff4_se*1.96

sort diff_4

twoway (dot diff_4 involvement, ndots(1) mcolor(gs2))(rcap upper4 lower4 involvement, lcolor(gs2)), /*
*/     xtitle("Political Oversight Capacity") xlabel(0 1 2) xsize(2.8) scale(1.4) ytitle("Effect of Full Aid Information") ylabel(-.4(.1) .3,nogrid)/*
*/   yscale(range(-.55 .4)) yline(0) title("Vote Choice") graphregion(fcolor(white) ifcolor(white) color(white) lcolor(white) ilcolor(white)) legend(off)
	  

graph export "figures_tables/Fig5_RightPanel_votechoice.tif", replace


***********************
*TABLE 6***************
***********************

preserve

keep if prior_Japan!=1 & prior_imp_ip!=1

sum credit if bypass==0 & involvement==0
reg credit bypass involvement bypassXinvolvement i.strata, cluster(id)
sum othersvote if bypass==0 & involvement==0
reg othersvote bypass involvement bypassXinvolvement i.strata, cluster(id)
sum vote if bypass==0 & involvement==0
reg vote bypass involvement bypassXinvolvement i.strata, cluster(id)

************************
*FIGURE 6***************
************************

reg credit bypass involvement bypassXinvolvement i.strata, cluster(id)

predictnl diff_2p = _b[bypass]+ _b[bypassXinvolvement]*involvement, se(diff2p_se)

gen upper2p = diff_2p + diff2p_se*1.96
gen lower2p = diff_2p - diff2p_se*1.96

sort diff_2

twoway (dot diff_2p involvement, ndots(1) mcolor(gs2))(rcap upper2p lower2p involvement, lcolor(gs2)), /*
*/     xtitle("Political Oversight Capacity") xlabel(0 1 2) xsize(2.8) scale(1.4) ytitle("Effect of Full Aid Information") ylabel(-.4(.1) .3,nogrid)/*
*/   yscale(range(-.55 .4)) yline(0) title("Credit Due") graphregion(fcolor(white) ifcolor(white) color(white) lcolor(white) ilcolor(white)) legend(off)
	  
graph export "figures_tables/Fig6_LeftPanel_creditduep.tif", replace
	  

reg othersvote bypass involvement bypassXinvolvement i.strata, cluster(id)

predictnl diff_3p = _b[bypass]+ _b[bypassXinvolvement]*involvement, se(diff3p_se)

gen upper3p = diff_3p + diff3p_se*1.96
gen lower3p = diff_3p - diff3p_se*1.96

sort diff_3p

twoway (dot diff_3p involvement, ndots(1) mcolor(gs2))(rcap upper3p lower3p involvement, lcolor(gs2)), /*
*/     xtitle("Political Oversight Capacity") xlabel(0 1 2) xsize(2.8) scale(1.4) ytitle("Effect of Full Aid Information") ylabel(-.4(.1) .3,nogrid)/*
*/   yscale(range(-.55 .4)) yline(0) title("Voting Factor") graphregion(fcolor(white) ifcolor(white) color(white) lcolor(white) ilcolor(white)) legend(off)
	  
graph export "figures_tables/Fig6_CenterPanel_votingfactorp.tif", replace
	  
	  
reg vote bypass involvement bypassXinvolvement i.strata, cluster(id)

predictnl diff_4p = _b[bypass]+ _b[bypassXinvolvement]*involvement, se(diff4p_se)

gen upper4p = diff_4p + diff4p_se*1.96
gen lower4p = diff_4p - diff4p_se*1.96

sort diff_4p

twoway (dot diff_4p involvement, ndots(1) mcolor(gs2))(rcap upper4p lower4p involvement, lcolor(gs2)), /*
*/     xtitle("Political Oversight Capacity") xlabel(0 1 2) xsize(2.8) scale(1.4) ytitle("Effect of Full Aid Information") ylabel(-.4(.1) .3,nogrid)/*
*/   yscale(range(-.55 .4)) yline(0) title("Vote Choice") graphregion(fcolor(white) ifcolor(white) color(white) lcolor(white) ilcolor(white)) legend(off)
	  

graph export "figures_tables/Fig6_RightPanel_votechoicep.tif", replace


restore

